import 'dart:async';

///future是一个异步任务的封装
///future出现的目的链式编程的实现
void main() {
  print("main begin ...");
  Future f = Future(() {
    print("future create ...");
    return 123;
  }).then((value) {
    print("future then1 value:$value...");
    // throw Error();
    return 567;
  }).then((value) {
    print("future then2 value:$value...");
  });
  f.onError((error, stackTrace) => print("出现异常,error:$error-- stackTrace:$stackTrace"));

  f.whenComplete(() => print("ok"));

  print("main end ...");

}
